package com.incar.chuxing.utils.Dialogs;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.incar.chuxing.R;

public class ChooseAvatarDialog extends Dialog {
    Context mContext;
    private OnItemClickListener onItemClickListener;//确定按钮被点击了的监听器

    public ChooseAvatarDialog(Context context) {
        super(context, R.style.navi_dialog);
        this.mContext = context;
    }

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_choose_avator);
        Window window = getWindow();
        window.setGravity(Gravity.BOTTOM);
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
        setCanceledOnTouchOutside(true);
        setCancelable(true);
        window.setWindowAnimations(R.style.dialog_choose_navi);
        initEvent();
    }


    /**
     * 初始化界面的确定和取消监听器
     */
    private void initEvent() {
        findViewById(R.id.navi_baidu).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null)
                    onItemClickListener.onClickItem(0);
            }
        });
        findViewById(R.id.navi_amap).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onItemClickListener != null)
                    onItemClickListener.onClickItem(1);
            }
        });

    }


    /**
     * 设置确定按钮的显示内容和监听
     *
     * @param onItemClickListener
     */
    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.onItemClickListener = onItemClickListener;
    }


    /**
     * 设置确定按钮和取消被点击的接口
     */
    public interface OnItemClickListener {
        void onClickItem(int position);
    }


}